package com.foreknow.elmboot_demo.controller;

import com.foreknow.elmboot_demo.mapper.OrdersMapper;
import com.foreknow.elmboot_demo.po.Orders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/OrdersController")
public class OrdersController {
    @Autowired
    private OrdersMapper ordersMapper;

    @RequestMapping("/createOrders")
    public int createOrders(Orders orders) {
        return ordersMapper.createOrders(orders);
    }

    @RequestMapping("/updateOrders")
    public int updateOrders(Orders orders) {
        return ordersMapper.updateOrders(orders);
    }

    @RequestMapping("/getOrdersById")
    public Orders getOrdersById(Integer orderId) {
        return ordersMapper.getOrdersById(orderId);
    }

    @RequestMapping("/listOrdersByUserId")
    public List<Orders> listOrdersByUserId(String userId) {
        return ordersMapper.listOrdersByUserId(userId);
    }
}
